#include"string.h"

namespace sty
{
	void test_string1()
	{
		string s1;
		string s2("hello world");
		cout << s1.c_str() << endl;
		cout << s2.c_str() << endl;
		for (size_t i = 0; i < s2.size(); i++)
		{
			s2[i] += 2;
		}
		cout << s2.c_str() << endl;
		for (auto e : s2)
		{
			cout << e << " ";
		}
		cout << endl;
		string::iterator it = s2.begin();
		while (it != s2.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}
	void test_string2()
	{
		string s1("hello world");
		s1 += 'x';
		s1 += '#';
		cout << s1.c_str() << endl;
		s1 += "111111";
		cout << s1.c_str() << endl;
		s1.insert(5, '2');
		cout << s1.c_str() << endl;
		s1.insert(0, '2');
		cout << s1.c_str() << endl;
		string s2("hello world");
		s2.insert(5, "mmmm");
		cout << s2.c_str() << endl;
	}
	void test_string3()
	{
		string s1("hello world");
		s1.erase(6,100);
		cout << s1.c_str() << endl;
		string s2("hello world");
		s2.erase(6);
		cout << s2.c_str() << endl;
		string s3("hello world");
		s3.erase(6,2);
		cout << s3.c_str() << endl;
	}
	void test_string4()
	{
		string s1("hello world");
		string s2("hello world");
		cout << s1.operator<(s2) << endl;
		cout << s1.operator==(s2) << endl;
		cout << (s1 < s2);

	}
}

int main()
{
	sty::test_string1();         //
	sty::test_string2();
	sty::test_string3();
	sty::test_string4();
	return 0;
}